Skip to content

feat(core): ingest queued sources in parallel - #63

Merged
francescobianco merged 1 commit into
openapi:mainfrom
jonxsong:codex/15-parallel-source-ingestion
Dec 4, 2026
Merged

francescobianco merged 1 commit into
openapi:mainfrom
jonxsong:codex/15-parallel-source-ingestion

Conversation

@jonxsong

@jonxsong jonxsong commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Queued ingestion waits for each source's analysis before starting the next. Remote model requests account for much of that wait. This change runs up to two source analyses at a time by default and accepts project settings of one to three workers.

Approach

  • Workers parse and analyze sources. The ingestion thread applies results in queue order, including retries, so shared entity resolution, Markdown writes, provenance, and queue transitions have one owner per open project instance.
  • The index and overview are rebuilt once per run. A pending refresh survives reopening the project and can be retried from the desktop without spending another provider call or replaying completed jobs.
  • Overlapping ChatGPT requests share model selection and token refresh. Streams can still overlap, and two requests rejected for the same token can reuse the refreshed token.
  • Cancellation lets active jobs finish and leaves later jobs queued. Existing project settings default to two workers, and the SQLite schema stays at version 1.

Regression and acceptance tests

  • On 911ee0e, the controlled provider peaked at one active call and the configurable worker setting was absent. The original max_jobs and restart control passed.
  • The tests require two and three simultaneous calls, out-of-order analysis completion with ordered wiki updates, one index and overview rebuild, and identical offline page bodies and provenance at worker counts one and two. They also exercise cancellation, recovery, a retry before later results publish, and preservation of a user-authored note.
  • A barrier test reproduced two refreshes for overlapping ChatGPT 401 responses on the original provider. It now records one refresh and both calls succeed.

Verification

  • python -m pytest -q on Linux with Python 3.12 passed all 65 tests on upstream and all 73 with this change. Windows passed 72 tests and reproduced upstream's existing POSIX file-mode assertion failure.
  • The eight focused tests passed in ten consecutive Python 3.12 runs on Windows. The standalone core suite also passed with Python 3.10 on Windows.
  • make test, make check, AppStream validation, desktop-file validation, Debian package build and installation, and the installed core import passed in Ubuntu 24.04. The validators used Linux line endings for the Windows checkout's copied build and desktop files.
  • A GTK 4.14.5/libadwaita 1.5.0 smoke test exercised the catalog error toast, retry after reopening, repair without replay, and saving Preferences with the worker setting preserved.
  • python -m build --no-isolation --outdir dist/issue15 . and build-aux/pypi/build.sh dist/issue15/mcp produced wheels and source distributions. git diff --check passed. The optional Ruff F check reported the same six diagnostics as upstream in the files reviewed.
  • make start-flatpak displayed a synthetic project inside the Flathub org.gnome.Platform//51 runtime on WSL2. A second smoke test inside the same runtime verified the catalog error toast, retry after reopening, both rebuilt files, no replay, and preservation of ingestion_workers=3 when saving Preferences. The runtime reported GTK 4.24.1 and libadwaita 1.10.0.

The catalog write error and Refresh Knowledge Index action in gknowledge

Compatibility

The worker setting is optional, existing sources and jobs keep their persisted formats, and offline analysis uses the same heuristics. The publication lock covers drains sharing an open Project instance. Concurrent mutations from independently opened project handles remain outside that lock. Provider verification used synthetic data and mocked or local providers.

Closes #15

AI assistance

Powered by OpenAI Codex: implementation and testing.

Checklist

  • make test passes
  • UI changes follow the GNOME HIG (and include a screenshot)
  • Any AI assistance used is mentioned in the description

@francescobianco

Copy link
Copy Markdown
Member

Thanks a lot @jonxsong, this is an excellent PR, and thanks for the clear write-ups on #7 and #15 too. 🙏

I've read the whole diff and run the suite on main with both #63 and #64 merged on top: 73 tests pass. What I like most is the split you chose: analysis runs in parallel, but the wiki is still written by one owner in queue order, so entity resolution and provenance stay deterministic. Rebuilding the index and overview once per batch, with a dirty marker that survives a restart, is a nice bonus. The ChatGPT token refresh under the shared lock is careful work as well.

One small, non-blocking note: ingestion_workers isn't in Preferences yet, so three workers is only reachable by editing gknowledge.json. That's fine for now; a spin row in Preferences could be a follow-up if you'd like it.

CI for fork PRs needs a maintainer to approve the run. That's on me now, and I'll merge this one first and then #64 as soon as it's green.


I'd love to have you in the official Openapi® contributors registry: https://github.com/openapi/contributors

It only takes a minute:

  1. Fork the repo
  2. Add your row to the table (template in the README comment), with openapi/gknowledge as your main project
  3. Open a Pull Request
  4. If you like, add the badge to your profile README:
[![Openapi® Contributor](https://img.shields.io/badge/Openapi%C2%AE-Contributor-753f8b)](https://github.com/openapi/contributors)

You'd be very welcome there. Thank you! 🚀

@francescobianco
francescobianco merged commit e9dcdb9 into openapi:main Dec 4, 2026
4 checks passed
@francescobianco

Copy link
Copy Markdown
Member

CI is green on every job (test, metadata, deb, flatpak), so this is merged, and #15 is closed with it. Thanks again @jonxsong! Parallel ingestion is the kind of speed-up people feel on their very first big import. It will ship in the next release. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ingest several sources in parallel

2 participants